/*************************************************
Author: tony
Date: 10/23/2012
Description:
Notes:
*************************************************/

#ifndef __cmdequipinfo_h__
#define __cmdequipinfo_h__

#include "../maindef.h"
#include "commclass.h"
#include "MsgEquipInfo.pb.h"
#include "../storage/CStorageMgr.h"

class CMainCtrl;
class CPlayerOnlineData;
class CSingleEquip;
class CEquipConfigData;
class CCmdEquipRole :	public CTAsyncCmd
{
public:
	enum
	{
		PARTNER_WEAR_EQUIP    = 1,    //穿装备
		PARTNER_TAKEOFF_EQUIP = 2,	  //脱装备
	};

	virtual int Do(void* pData);
    virtual int AnsClients(int iRet);
    virtual int LogicDo(int iRet);

    CMainCtrl* pstMainCtrl;
    PBMsgHead  stMsgHead;
    CEnpNetHead stEnpHead;

    MsgReqEquipRole stReq;
    MsgAnsEquipRole stAns;    

private:    
    CStorageGrid  _stBagGrid;    //背包中的格子
    CStorageGrid  _stRoleGrid;   //人物身上的格子    
    unsigned int _uiGid;
    int PreCheck (CPlayerBaseInfo & , CPlayerDetailInfo &, CPlayerOnlineData &);
    int TakeoffEquip (CPlayerBaseInfo & , CPlayerDetailInfo &, CPlayerOnlineData &);
    int WareEquip (CPlayerBaseInfo & , CPlayerDetailInfo &, CPlayerOnlineData &);
    int PutEquipToBag (CPlayerDetailInfo &, CPlayerOnlineData & stPlayerOnlineData);
    int GetEquipOnRole (CPlayerDetailInfo &, short shRoleId, unsigned char ucEquipPos, unsigned int & uiNowEquip);
};

//获取合成装备的材料信息
class CCmdEquipMakeInfo : public CTAsyncCmd
{
public:

	virtual int Do(void* pData);
	virtual int AnsClients(int iRet);
	virtual int LogicDo(int iRet);

	CMainCtrl* pstMainCtrl;
	PBMsgHead  stMsgHead;
	CEnpNetHead stEnpHead;
    int GetEquipMakeInfo (CPlayerOnlineData& stPlayerOnlineData, unsigned int uiEquipId);

	MsgReqEquipMakeInfo stReq;
	MsgAnsEquipMakeInfo stAns;
    unsigned int _uiGID;
};

class CScrollConfigData;
//装备合成
class CCmdEquipMake : public CTAsyncCmd
{
public:
    CCmdEquipMake ()
    {
        _iNeedGold = 0;        
    }

	virtual int Do(void* pData);
    virtual int AnsClients(int iRet);
    virtual int LogicDo(int iRet);

    CMainCtrl* pstMainCtrl;
    PBMsgHead  stMsgHead;
    CEnpNetHead stEnpHead;
	MsgReqEquipMake stReq;
	MsgAnsEquipMake stAns;
    unsigned int _uiGID;
private:
    int PreCheck (CPlayerBaseInfo & , CPlayerDetailInfo &, CPlayerOnlineData &);
    int TakeoffEquip (CPlayerBaseInfo & , CPlayerDetailInfo &, CPlayerOnlineData &);
	int WareEquip (CPlayerBaseInfo & , CPlayerDetailInfo &, CPlayerOnlineData &);

private:
    int _iNeedGold;    //合成需要的金币数
    CSingleEquip _stEquip;  
    CStorageGrid _stScrollGrid; //卷轴所在格子
    CStorageGrid _stEquipGrid;  //装备所在格子    
    CScrollConfigData _stScrollConfig; //卷轴的配置
};

//装备强化
class CCmdEquipStrength : public CTAsyncCmd
{
public:
	enum
	{
		OPER_REQ_INFO = 1,
		OPER_REQ_STRENGTH = 2,
	};
	virtual int Do(void* pData);
    virtual int AnsClients(int iRet);
    virtual int LogicDo(int iRet);

    CMainCtrl* pstMainCtrl;
    PBMsgHead  stMsgHead;
    CEnpNetHead stEnpHead;

    MsgReqEquipStrength stReq;
    MsgAnsEquipStrength stAns;

    unsigned int _uiGID;
};

class CCmdEquipCrystal : public CTAsyncCmd
{
public:
	enum{
		OPER_INSET_CRYSTAL = 1,  //镶嵌
		OPER_UNSET_CRYSTAL = 2,  //拆除
		OPER_COMB_CRYSTAL    = 3, //合成
		OPER_ONEKEY_CRYSTAL  = 4, //一键合成
        OPER_DECOMPOSE_CRYSTAL = 5, //魔晶分解
        OPER_COMPOSE_CRYSTAL   = 6, //魔晶合成
        OPER_ELEVATE_POTEN  = 7,   //提升魔晶潜能
	};

	virtual int Do(void* pData);
    virtual int AnsClients(int iRet);
    virtual int LogicDo(int iRet);

	CMainCtrl* pstMainCtrl;
    PBMsgHead  stMsgHead;
    CEnpNetHead stEnpHead;

	MsgReqEquipCrystal stReq;
	MsgAnsEquipCrystal stAns;
	unsigned int _uiGID;
private:
    int GetCrystalEquipId(unsigned int & uiEquipID);
    int CheckLevel(short sPlayerLevel, unsigned char ucCombLevel);
    int ElevatePoten (CPlayerBaseInfo & stBaseInfo,  CPlayerDetailInfo & stDetailInfo, CPlayerOnlineData & stOnlineData);
};

//装备洗练
class CCmdEquipRefine : public CTAsyncCmd
{
public:
    virtual int Do(void* pData);
    virtual int AnsClients(int iRet);
    virtual int LogicDo(int iRet);

    CMainCtrl* pstMainCtrl;
    PBMsgHead  stMsgHead;
    CEnpNetHead stEnpHead;

    MsgReqEquipRefine stReq;
    MsgAnsEquipRefine stAns;

    unsigned int _uiGID;
};

//装备祝福
class CCmdEquipBless : public CTAsyncCmd
{
public:
    virtual int Do(void* pData);
    virtual int AnsClients(int iRet);
    virtual int LogicDo(int iRet);

    CMainCtrl* pstMainCtrl;
    PBMsgHead  stMsgHead;
    CEnpNetHead stEnpHead;

    MsgReqEquipBless stReq;
    MsgAnsEquipBless stAns;

    unsigned int _uiGID;
};


#endif // __cmdequipinfo_h__

